<?php defined('SYSPATH') or die('No direct script access.');

class Model_Reg {
	
	private static $instance;

	private $vars;

	public static function instance() {
		if (self::$instance === NULL) {
			self::$instance = new Model_Reg;
			self::$instance->vars = array();
		}
		return self::$instance;
	}

	public static function set($var, $value) {
		self::instance()->vars[$var] = $value;
	}

	public static function get($var, $default = NULL) {
		if ( ! self::is_exists($var)) {
			return $default;
		}
		return self::instance()->vars[$var];
	}

	public static function del($var) {
		if (self::is_exists($var)) {
			unset(self::instance()->vars[$var]);
		}
	}

	public static function is_exists($var) {
		return isset(self::instance()->vars[$var]) ? TRUE : FALSE;
	}

	public static function export_vars() {
		$vars = self::instance()->vars;
		return (is_array($vars)) ? $vars : array();
	}

	public function __get($var) {
		return self::instance()->vars[$var];
	}

	public function __set($var, $val) {
		self::instance()->vars[$var] = $val;
	}
	
}